﻿<div ng-controller="Approval_IndexC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">审批列表</h1>
    </div>
    <div class="wrapper-md" style="text-align: center;">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12" style="float: right">
                </div>
                <!--<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 input-group">-->
                    <!--<input type="text" class="form-control" placeholder="按名称查找" ng-model="findname">-->
                    <!--<span class="input-group-btn">-->
                        <!--<button class="btn btn-default" type="button" ng-click="find()">查找</button>-->
                    <!--</span>-->
                <!--</div>-->
            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light table-bordered">
                    <thead>
                        <tr>
                            <th style="text-align: center;">类型</th>
                            <th style="text-align: center;">申请人</th>
                            <th style="text-align: center;">标题</th>
                            <th style="text-align: center;">状态</th>
                            <th style="text-align: center;">创建时间</th>
                            <th style="text-align: center;">操作</th>

                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in pageData.Data">
                            <td>{{item.TypeName}}</td>
                            <td>{{item.Creater.Name}}</td>
                            <td>{{item.Title }}</td>
                            <td>{{getState(item.ApprovalState)}}</td>
                            <td>{{item.CreateTime| limitTo:16}}</td>
                            <td>
                                <button class="btn btn-sm btn-default" ng-disabled="{{item.ApprovalState==2||item.ApprovalState==3}}" ng-click="ToDetail(item)">
                                    <i class="fa fa-cogs text"></i>
                                    <span class="text">管理</span>
                                </button>
                                <button class="btn btn-sm btn-default" ng-click="ToDetail(item)">
                                    <i class="fa fa-cogs text"></i>
                                    <span class="text">详情</span>
                                </button>
                            </td>

                        </tr>
                    </tbody>
                </table>
                <div class="panel-heading" my-pagination get-page-data="getData" mypagedata="pageData"></div>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')//非标优惠
.controller("Approval_IndexC", function ($scope, $state, $http,toSave) {
    $scope.pageData = {};
    $scope.pageData.Page = 0;
    $scope.pageData.Rows = $scope.defPageRows;
    //
    $scope.getData = function (p , r) {
        if (p) {
            p = p < 1 ? 1 : p;
        } else p = 1;
        if (r) {
        } else r = $scope.defPageRows;
        toSave.save_pages_lis(p, r);//保存当前页码和条数
       $http({
           url: "/api/Approval/List?page=" + p + "&rows=" + r,
           method: "GET",
           data: {title:"",state:""}
           })
       .then(function (res) {
               $scope.pageData = res.data;
           console.log($scope.pageData);
       })
       .then(function (error) {
           if (error) {
               alert("数据获取失败");
           }
       });
   };
    $scope.getData(toSave.get_pages(), $scope.pageData.Rows);
    $scope.go= function(id) {
        $state.go('app.Approval_Details', { 'id': id });
    };
    $scope.getState= function(state) {
        var stObj = {0:"待审批",1:"审批中",2:"通过",3:"驳回"};
        return stObj[state];
    };
    $scope.ToDetail = function(item){
        console.log(item.TypeName);
        if(item.TypeName == "采购审批"){
            $state.go('app.Approval_PurchasingDetails', { 'id': item.Id })
        }else if(item.TypeName == "议价审批" || item.TypeName == "锁价审批" || item.TypeName == "取消计划单审批" || item.TypeName == "订单退货" || item.TypeName == "订单退款"){
            $state.go('app.Approval_Details', { 'id': item.Id })
        }else if(item.TypeName == "锁价单审批" || item.TypeName == "锁价单退款"){
            $state.go('app.Approval_LockOrderManage', { 'id': item.Id })
        }else if(item.TypeName == "财务退款审批"){
            $state.go('app.Approval_RefundManage', { 'id': item.Id })
        }else if(item.TypeName == "报价审批"){
            $state.go('app.Approval_PriceConfirmDatas', { 'id': item.Id })
        }
    }
    })

</script>
<script src="js/services/toSave.js"></script>


